package com.vis.mybatisflex.mapper;

import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;

/**
 * Mapper 扩展
 */
public interface ZBMapper<T> extends BaseMapper<T> {
    /**
     * 默认批量处理切片数量。
     */
    int DEFAULT_BATCH_SIZE = 1000;

    default T selectColumnById(String id, String... column) {
        return selectColumnByKey("id", id, column);
    }

    default T selectColumnByKey(String key, String value, String... column) {
        if (column == null || column.length == 0) {
            column = new String[]{" * "};
        }
        QueryWrapper query = QueryWrapper.create().select(column).eq(key, value);
        return selectOneByQuery(query);
    }

}
